// router/index.js
import {createRouter, createWebHistory} from 'vue-router';

// 导入页面组件
import Home from '../views/Home.vue';
import About from '../views/About.vue';
import Knowledge from '../views/knowledge/Index.vue'; // 旧的，可以保留或删除


// 定义路由规则
const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home,
        meta: {title: '首页', hidden: false}
    },
    {
        path: '/readme',
        name: 'Readme',
        component: () => import('../views/AboutMe.vue'),
        meta: {title: '我的', hidden: true}
    },
    {
        path: '/manager',
        name: 'Manager',
        component: () => import('../views/ModuleLayout.vue'),
        meta: {title: '应用监测', hidden: false},
        redirect: '/manager/trace',
        children: [
            {
                path: 'trace',
                name: 'Trace',
                component: () => import('../views/monitor/TraceView.vue'),
                meta: {title: '服务追踪'}
            },
            {
                path: 'metrics',
                name: 'Metrics',
                component: () => import('../views/monitor/BaseResource.vue'),
                meta: {title: '基础资源监控'}
            }
        ]
    },
    // --- 新增的知识管理路由 ---
    {
        path: '/knowledge',
        name: 'Knowledge',
        component: () => import('../views/ModuleLayout.vue'),
        meta: {title: '知识管理', hidden: false, icon: 'Document'}, // 假设你用 Element Plus 的图标
        redirect: '/knowledge/overview',
        children: [
            {
                path: 'overview',
                name: 'KnowledgeOverview',
                component: () => import('../views/knowledge/Overview.vue'),
                meta: {title: '概览', icon: 'Odometer'}
            },
            {
                path: 'manage',
                name: 'KnowledgeManage',
                component: () => import('../views/knowledge/Manage.vue'),
                meta: {title: '知识管理', icon: 'Files'}
            }
        ]
    },
    {
        path: '/knowledgeBase', // 你原来的路径，可以考虑删除或重定向
        name: 'KnowledgeBase',
        component: Knowledge,
        meta: {title: '知识库', hidden: true}
    },
    {
        path: '/about',
        name: 'About',
        component: About,
        meta: {title: '关于', hidden: true}
    },
    {
        path: '/:pathMatch(.*)*',
        name: 'NotFound',
        component: () => import('../views/common/NotFound.vue'), // ✅ 添加组件
        meta: {hidden: true} // 隐藏此路由
    }
];

// 创建路由实例
const router = createRouter({
    history: createWebHistory(),
    routes,
});

export default router;
